package com.jyh.common;

/**
 * 响应数据
 * 泛型方法，在使用该类的时候，指定引用具体类型，灵活
 */

public class R<T> {
    private Integer code;
    private String msg;
    private T data;


    public static <T> R<T> success(T object){
        R<T> o = new R<T>();
        o.data=object;
        o.code=1;
        return o;
    }

    public static <T> R<T> error(String msg){
        R o = new R();
        o.msg=msg;
        o.code=0;
        return  o;
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public R() {
    }

    //不用有参构造器也行


//    public R(Integer code, String msg, T data) {
//        this.code = code;
//        this.msg = msg;
//        this.data = data;
//    }
//
//    public R(T data) {
//        this.data = data;
//    }
}
